package gui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.WindowConstants;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class VerProveedores extends javax.swing.JFrame {

	private static final long serialVersionUID = 1L;
	private JLabel lblTitle;
	private JTextField txtCodigo;
	private JTextField txtRazSoc;
	private JLabel lblRazSoc;
	private JLabel lblCodigo;
	private JButton cmdBuscar;
	private JTable tbProveedores;
	private JScrollPane spProveedores;
	private JButton cmdVolver;
	private static VerProveedores instance;
	private JRadioButton rdBuscar;
	private JRadioButton rdTodos;
	
	public VerProveedores() {
		super();
		initGUI();
		this.setLocationRelativeTo(null);
	}
	
	public static VerProveedores getInstance()
	{
		if (instance == null)
			instance = new VerProveedores();
		
		return instance;
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName());
			{
				lblTitle = new JLabel();
				getContentPane().add(lblTitle);
				lblTitle.setText("CPR - Proveedores - Ver Proveedores");
				lblTitle.setFont(new java.awt.Font("Calibri",0,20));
				lblTitle.setBounds(12, 12, 373, 32);
			}
			{
				cmdVolver = new JButton();
				getContentPane().add(cmdVolver);
				cmdVolver.setText("Volver");
				cmdVolver.setBounds(24, 319, 91, 31);
				cmdVolver.setFont(new java.awt.Font("Calibri",0,16));
				cmdVolver.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						cmdVolverActionPerformed(evt);
					}
				});
			}
			{
				ButtonGroup group = new ButtonGroup();
				group.add(getRdBuscar());
				group.add(getRdTodos());
			}
			getContentPane().add(getRdBuscar());
			getContentPane().add(getRdTodos());
			getContentPane().add(getSpProveedores());
			getContentPane().add(getCmdBuscar());
			getContentPane().add(getTxtCodigo());
			getContentPane().add(getTxtRazSoc());
			getContentPane().add(getLblCodigo());
			getContentPane().add(getLblRazSoc());
			pack();
			setSize(600, 400);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	private JRadioButton getRdBuscar() {
		if(rdBuscar == null) {
			rdBuscar = new JRadioButton();
			rdBuscar.setText("Buscar");
			rdBuscar.setBounds(34, 65, 80, 23);
			rdBuscar.setFont(new java.awt.Font("Calibri",0,14));
			rdBuscar.setSelected(true);
			rdBuscar.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) {
					rdBuscarActionPerformed(evt);
				}
			});
		}
		return rdBuscar;
	}
	
	private JRadioButton getRdTodos() {
		if(rdTodos == null) {
			rdTodos = new JRadioButton();
			rdTodos.setText("Todos");
			rdTodos.setBounds(116, 65, 106, 23);
			rdTodos.setSelected(false);
			rdTodos.setFont(new java.awt.Font("Calibri",0,14));
			rdTodos.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) {
					rdTodosActionPerformed(evt);
				}
			});
		}
		return rdTodos;
	}
	
	//Actions
	private void cmdVolverActionPerformed(ActionEvent evt) {
		this.dispose();
	}
	
	private void rdTodosActionPerformed(ActionEvent evt)
	{
		
	}
	
	private void rdBuscarActionPerformed(ActionEvent evt)
	{
		
	}
	
	private JScrollPane getSpProveedores() {
		if(spProveedores == null) {
			spProveedores = new JScrollPane();
			spProveedores.setBounds(262, 65, 312, 254);
			spProveedores.setFont(new java.awt.Font("Calibri",0,14));
			spProveedores.setViewportView(getTbProveedores());
		}
		return spProveedores;
	}
	
	private JTable getTbProveedores() {
		if(tbProveedores == null) {
			TableModel tbProveedoresModel = 
					new DefaultTableModel(
							new String[][] { { "1", "Two", "2", "2012" }},
							new String[] { "Codigo", "Razon Social", "Nro Cuit", "Ultima Lista Publicada" });
			tbProveedores = new JTable();
			tbProveedores.setModel(tbProveedoresModel);
			getTbProveedores().getTableHeader().setFont(new java.awt.Font("Calibri",0,14));
		}
		return tbProveedores;
	}
	
	private JButton getCmdBuscar() {
		if(cmdBuscar == null) {
			cmdBuscar = new JButton();
			cmdBuscar.setText("Buscar");
			cmdBuscar.setBounds(157, 207, 75, 23);
			cmdBuscar.setFont(new java.awt.Font("Calibri",0,14));
		}
		return cmdBuscar;
	}
	
	private JTextField getTxtCodigo() {
		if(txtCodigo == null) {
			txtCodigo = new JTextField();
			txtCodigo.setBounds(157, 125, 75, 20);
			txtCodigo.setFont(new java.awt.Font("Calibri",0,14));
		}
		return txtCodigo;
	}
	
	private JTextField getTxtRazSoc() {
		if(txtRazSoc == null) {
			txtRazSoc = new JTextField();
			txtRazSoc.setBounds(157, 167, 75, 20);
			txtRazSoc.setFont(new java.awt.Font("Calibri",0,14));
		}
		return txtRazSoc;
	}
	
	private JLabel getLblCodigo() {
		if(lblCodigo == null) {
			lblCodigo = new JLabel();
			lblCodigo.setText("Codigo");
			lblCodigo.setBounds(95, 128, 52, 14);
			lblCodigo.setFont(new java.awt.Font("Calibri",0,14));
		}
		return lblCodigo;
	}
	
	private JLabel getLblRazSoc() {
		if(lblRazSoc == null) {
			lblRazSoc = new JLabel();
			lblRazSoc.setText("Razon Social");
			lblRazSoc.setBounds(62, 170, 76, 14);
			lblRazSoc.setFont(new java.awt.Font("Calibri",0,14));
		}
		return lblRazSoc;
	}

}
